home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 September / CHIP Eylül 1998.iso / Slackwar / docs / mini / Backup-With-MSDOS < prev    next >
Text File  |  1997-08-11  |  18KB  |  428 lines

  1.   Backup-With-MSDOS mini-HOWTO
  2.   Christopher Neufeld, neufeld@physics.utoronto.ca
  3.   Aug 5, 1997
  4.  
  5.   This HOWTO describes how to use a Linux-compatible tape drive
  6.   installed on an MS-DOS machine to back up the filesystem of a Linux
  7.   machine.
  8.  
  9.   1.  Preface/Introduction
  10.  
  11.   Earlier I posed the question on the Net, how does one back up a Linux
  12.   machine to a Colorado Jumbo 250 tape drive on an MS-DOS machine.  From
  13.   the email I received, it seems that this is a frequently pondered
  14.   problem.  Now that I've figured it out, I'm posting the method.  If
  15.   anybody wants to massage this into a HOWTO document, let me know.  I
  16.   should thank Jim Nance (jlnance@isscad.com) for pointing out that an
  17.   MS-DOS machine need not always be an MS-DOS machine.  This technique
  18.   should also work for any other tape drive supported by the ftape
  19.   module, and for SCSI tape drives with suitable obvious changes (i.e.
  20.   substituting /dev/st0 for /dev/ftape).
  21.  
  22.   The criteria I set were that the resulting setup should be as secure
  23.   as possible and should be fairly simple, and take up little or no
  24.   space on the MS-DOS machine's hard drive. It should also be capable of
  25.   recovering from the worst system corruptions, up to and including the
  26.   theft of the hard disk, requiring a restore to a bare Linux file
  27.   system.  The technique described here uses no hard drive space on the
  28.   MS-DOS machine, though it requires that that machine be assigned an
  29.   IP#.  You will need three formatted, blank 1.44MB diskettes.
  30.  
  31.   2.  The technique
  32.  
  33.   Throughout this description I will refer to two machines as ``msdos''
  34.   and ``linux''. ``msdos'' is the name of the machine which has the tape
  35.   drive and is usually running MS-DOS.  ``linux'' is the Linux machine
  36.   whose disk you are trying to back up or restore to the tape drive.
  37.   For simplicity I will refer to the first machine as ``msdos'' even
  38.   when it is booted into and running Linux.  Further, all path names in
  39.   this document should be considered to be relative to the Linux machine
  40.   with the Search-And-Rescue (SAR) disks mounted somewhere on the
  41.   system.  That means that the file /etc/passwd is the password file for
  42.   your Linux machine's hard drive, while, for instance,
  43.   /tape144/etc/passwd is the corresponding file on the floppy disk.
  44.  
  45.   I am using Karel Kubat's backup scripts, version 1.03, available at
  46.  
  47.        <ftp://sunsite.enc.edu:/pub/Linux/system/Backup/backup-1.03.tar.gz>
  48.  
  49.   Throughout this document I will refer to these simply as ``the backup
  50.   scripts''.  You do not have to use these scripts for your own backups
  51.   to tape.  I like these scripts as they use afio to form an uncom¡
  52.   pressed archive of compressed files, rather than a compressed archive
  53.   of uncompressed files.  The former is much safer if there is a media
  54.   read error during the restore.  I understand that Karel is no longer
  55.   supporting backup, and now has produced 'tob', or tape oriented
  56.   backup.  While I haven't tried the new package myself, it cannot make
  57.   a significant difference to the procedure outlined here.
  58.  
  59.   First of all, obtain the ftape module. It is a part of all modern
  60.   kernels, but if you are using an older kernel you can find the module
  61.   at:
  62.  
  63.        <ftp://sunsite.unc.edu/pub/Linux/kernel/tapes/ftape-2.05.tar.gz>
  64.  
  65.   Next, get a Slackware boot disk (I got the net disk, but it doesn't
  66.   make much difference) and the tape144 root disk, and put the images
  67.   onto 3"1/2 floppies.
  68.  
  69.   The ftape module will only work if it is installed in the kernel which
  70.   was running when you compiled it.  I could not get it to work with the
  71.   ftape.o module on the tape144 root disk, I think because that module
  72.   has been stripped of symbols and won't install.  So, you now have to
  73.   make a new kernel with network and ftape support, and if you're
  74.   running an old kernel, a new ftape.o.  Read the directions which ship
  75.   with the ftape archive for directions at this stage.  Remember that
  76.   the kernel you compile must support the Ethernet cards on both the
  77.   Linux machine and the MS-DOS machine.
  78.  
  79.   Copy the newly created kernel image over top of the one on the Net
  80.   boot disk.  Use /bin/cp, do not create a boot disk with the ``dd''
  81.   command as you would to create a bootable kernel image.  Write protect
  82.   the boot disk, and label it: SAR#1.
  83.  
  84.   Now, mount the tape144 root disk.  I'll assume that the mount point is
  85.   /tape144, to avoid confusion in file names.  We need to free some
  86.   space on it, so delete the following files:
  87.  
  88.        /tape144/bin/dialog
  89.        /tape144/bin/elvis
  90.        /tape144/bin/vi
  91.        /tape144/boot/ftape.o
  92.  
  93.   Now, create a new file:
  94.  
  95.        /tape144/etc/exports
  96.  
  97.   which contains the following line:
  98.  
  99.        /mnt    msdos(ro)
  100.  
  101.   Where ``msdos'' should be replaced with the name or IP# of the MS-DOS
  102.   machine which has the tape drive installed.
  103.  
  104.   Next, so that you don't have to rely on a name server, add lines to
  105.   the file /tape144/etc/hosts with the names and IP numbers of the Linux
  106.   and MS-DOS machines.  For instance, mine contains the following two
  107.   lines:
  108.  
  109.        128.100.75.114  caliban.physics.utoronto.ca caliban caliban.physics
  110.        128.100.75.111  ariel.physics.utoronto.ca ariel ariel.physics
  111.  
  112.   Now, there's some sort of problem with the inetd configuration.  We
  113.   have to put the full path name of the rsh daemon in it.  Change line
  114.   19 of /tape144/etc/inetd.conf to read:
  115.        shell   stream  tcp     nowait  root    /usr/etc/tcpd   /usr/etc/in.rshd
  116.  
  117.   Add local net routing information to /tape144/etc/rc.d/rc.inet1 to
  118.   enable the MS-DOS machine to use the network.  The format of this
  119.   depends on your network configuration, you can just copy the
  120.   appropriate format out of your Linux /etc/rc.d/rc.inet1.  For my
  121.   network, the lines that have to be added are:
  122.  
  123.        /etc/ifconfig eth0 128.100.75.111 broadcast 128.100.75.0 netmask 255.255.255.0
  124.        /etc/route add -net 128.100.75.0 netmask 255.255.255.0
  125.  
  126.   The IP# in the ifconfig entry is that of the MS-DOS machine.
  127.  
  128.   Now, copy this file into /tape144/etc/rc.d/rc.inet1-l, and change the
  129.   IP# in the new file to reflect that of the Linux machine rather than
  130.   the MS-DOS machine.
  131.  
  132.   Next, clip out lines 3 to 11 of /tape144/etc/rc.local.  That's an if
  133.   statement which executes the rc.inet* files.  We don't want this to
  134.   happen during the bootup.
  135.  
  136.   Create a new file: /tape144/root/.rhosts containing the line:
  137.  
  138.        linux root
  139.  
  140.   where, again, ``linux'' is replaced with the full machine name
  141.   (including domain) or the IP# of the Linux machine.
  142.  
  143.   Fill in the password field in /tape144/etc/passwd for the root login
  144.   to keep people from logging onto the MS-DOS machine while you're doing
  145.   the backup.  You can do this by copying the corresponding field from
  146.   your Linux machine's /etc/passwd file.
  147.  
  148.   Copy /usr/bin/rsh into /tape144/usr/bin.
  149.  
  150.   Copy the following files from /usr/etc into /tape144/usr/etc:
  151.  
  152.        in.rshd
  153.        rpc.mountd
  154.        rpc.nfsd
  155.        rpc.portmap
  156.        services
  157.        tcpd
  158.  
  159.   Create a new script, /tape144/bin/tapesetup, which consists of the
  160.   following: (change ``linux'' to reflect your Linux machine name).
  161.  
  162.   #! /bin/sh
  163.  
  164.   /bin/sh /etc/rc.d/rc.inet1
  165.   /bin/sh /etc/rc.d/rc.inet2
  166.  
  167.   /bin/mount linux:/nfs /mnt
  168.   /bin/insmod /mnt/ftape.o
  169.  
  170.   Note that newer kernels will not require the insmod line.
  171.  
  172.   Next, create another new script, /tape144/bin/msdosset, as follows:
  173.   (change ``linux'' to reflect your Linux machine name).
  174.  
  175.        #! /bin/sh
  176.  
  177.        /bin/sh /etc/rc.d/rc.inet1
  178.        /bin/sh /etc/rc.d/rc.inet2
  179.  
  180.        mount linux:/mnt /mnt
  181.        /bin/insmod /mnt/ftape.o
  182.  
  183.   As above, newer kernels will not require the insmod line.
  184.  
  185.   Create a readable file, /tape144/root/notes, which contains this
  186.   helpful information for use in full recovery:
  187.  
  188.        For a full recovery to a trashed hard disk,
  189.        boot the Linux machine with the SAR disks #1 and #2
  190.        then type the following:
  191.  
  192.           /bin/sh /etc/rc.d/rc.inet1-l
  193.           /bin/sh /etc/rc.d/rc.inet2
  194.  
  195.           /usr/etc/rpc.portmap
  196.           /usr/etc/rpc.mountd
  197.           /usr/etc/rpc.nfsd
  198.  
  199.        Next, insert SAR disk #3 and type:
  200.  
  201.           mount /dev/fd0 /mnt
  202.  
  203.        Create a new mount point, with:
  204.  
  205.           mkdir /mnt2
  206.  
  207.        and mount your Linux hard disk partition on this point.
  208.        You may have to reformat the partition first, if so,
  209.        follow the directions in the Linux Installation HOWTO.
  210.        The SAR disks contain all the files necessary to do the reformat.
  211.  
  212.        Finally, use disks SAR#1 and SAR#2 to boot up
  213.        the MS-DOS machine and run the /bin/msdosset script on that machine.
  214.        It will take about a minute to run that script because it is getting
  215.        an NSF file from a floppy drive, so be patient.
  216.        Now, recover the tape to /mnt2 on the Linux machine.
  217.  
  218.   If you are using the backup scripts you will need to copy 'afio' into
  219.   the /tape144/local/bin subdirectory.  It is not necessary to have the
  220.   rest of the backup script files on the recovery disks, an archive can
  221.   be recovered using only 'afio' and 'gzip'.
  222.  
  223.   I was unable to use the backup scripts as they come shipped.  The tape
  224.   archive appears to build cleanly, but it is unrecoverable.  I found
  225.   that removing the block size and conversion statements fixed it.  Here
  226.   is the patch to the ``netbackup'' script.  Apply this patch to the
  227.   Linux machine's hard disk copy of 'netbackup' as well as to the copy
  228.   on the SAR disks.
  229.  
  230.        *** netbackup.orig      Mon Jan  9 17:22:32 1995
  231.        --- netbackup   Mon Jan  9 17:23:25 1995
  232.        ***************
  233.        *** 35,41 ****
  234.                          "'mknod", devname, "p'");
  235.              exec ("su -", USERNAME, "-c",
  236.                          "'rsh ", REMOTE_HOST,
  237.        !                       "\"dd", "of=" REMOTE_DEVICE, "obs=20k", "conv=sync\"",
  238.                                "<", devname,
  239.                        "'&"
  240.                 );
  241.        --- 35,41 ----
  242.                          "'mknod", devname, "p'");
  243.              exec ("su -", USERNAME, "-c",
  244.                          "'rsh ", REMOTE_HOST,
  245.        !                       "\"dd", "of=" REMOTE_DEVICE, "\"",
  246.                                "<", devname,
  247.                        "'&"
  248.                 );
  249.        ***************
  250.        *** 50,56 ****
  251.                          "'mknod", devname, "p'");
  252.              exec ("su", USERNAME, "-c",
  253.                          "'rsh ", REMOTE_HOST,
  254.        !                       "\"dd", "if=" REMOTE_DEVICE, "ibs=20k", "conv=sync\"",
  255.                                ">", devname,
  256.                        "'&"
  257.                 );
  258.        --- 50,56 ----
  259.                          "'mknod", devname, "p'");
  260.              exec ("su", USERNAME, "-c",
  261.                          "'rsh ", REMOTE_HOST,
  262.        !                       "\"dd", "if=" REMOTE_DEVICE, "\"",
  263.                                ">", devname,
  264.                        "'&"
  265.                 );
  266.  
  267.   You have now finished your SAR disk #2.  Write protect it.
  268.  
  269.   Next, mount a clean, formatted disk (create it with fdformat and
  270.   mkfs).  Copy the ftape.o file onto it, and label it SAR#3.  For some
  271.   reason things go badly if you write protect this disk, so leave it
  272.   write-enabled.
  273.  
  274.   On the Linux machine, create a new directory for NFS file serving.  I
  275.   made a directory:
  276.  
  277.        /nfs
  278.  
  279.   Put the ftape.o (unstripped, about 500+ kB) into this subdirectory.
  280.   Create an entry in your Linux's exports file /etc/exports:
  281.  
  282.        /nfs    msdos(ro)
  283.  
  284.   Note that all files in your NFS directory and it's subdirectories are
  285.   not secure.  Somebody else could boot the MS-DOS machine into Linux
  286.   with his own boot disks and mount this directory, so be certain that
  287.   you don't put anything sensitive in your NFS subdirectory.
  288.  
  289.   Restart your NFS daemons, rpc.mountd and rpc.nfsd.  They don't seem to
  290.   take kindly to a SIGHUP restart, so kill them and reinvoke them.  If
  291.   you're not activating these daemons in your /etc/rc.d/rc.inet2 you
  292.   might want to do so now.
  293.  
  294.   OK, now we're all set to back up and recover.  To make a full backup
  295.   from the Linux machine, boot the MS-DOS machine with SAR#1.  When
  296.   prompted for the second disk, load SAR#2. Log in as root, and execute
  297.   the script: /bin/tapesetup.  Log out of the MS-DOS machine.  If you're
  298.   using the backup scripts, the netbackup command will now work.  You
  299.   can also use the ``-f msdos:/dev/ftape'' switch on GNU tar, cpio, or
  300.   mt, and make your backup this way.  If you have a backup program,
  301.   which is only capable of writing to a local file, do the following.
  302.   Assume that the backup program is called ``localbackup'' and writes to
  303.   the file represented by its command line argument:
  304.  
  305.        mknod /tmp/tapepipe p
  306.        rsh msdos dd of=/dev/ftape < /tmp/tapepipe &
  307.        localbackup /tmp/tapepipe
  308.  
  309.   when it's done, delete /tmp/tapepipe.
  310.  
  311.   Recovering to a live Linux machine: the netbackup script, tar, cpio,
  312.   and so on will all work without special actions on the part of the
  313.   operator.  If you have a local recovery program which recovers from a
  314.   file, do this:
  315.  
  316.        mknod /tmp/tapepipe p
  317.        rsh -n msdos dd if=/dev/ftape >> /tmp/tapepipe &
  318.        localrecovery /tmp/tapepipe
  319.  
  320.   and delete /tmp/tapepipe when you're done.
  321.  
  322.   Notice that I'm using 'rsh' to the root user on the MS-DOS machine.
  323.   This works with a correct .rhosts entry.  The configuration on the
  324.   'tape144' disk allows rsh to root, but does not allow telnet or rlogin
  325.   to root, logins are restricted to the console.  This is good for
  326.   security.
  327.  
  328.   If you are worried about a root .rhost file, you can create a new user
  329.   on SAR#2, ``tapeuser'', with permissions to operate the tape drive but
  330.   not the disks (create a new group and put tapeuser in that group, then
  331.   chown and chmod the files /dev/rft* and /dev/nrft*).  Your backup
  332.   program then has to know to rsh to that username rather than to root.
  333.   Of course, now there must be an .rhosts file in ~tapeuser on SAR#2.
  334.   For my own use, I have chosen this course, rather than a root .rhosts.
  335.  
  336.   Finally, the directions for a complete recovery to a trashed hard
  337.   disk.  This assumes that the Linux partition is completely
  338.   unrecoverable.  If necessary, reformat that partition as described in
  339.   the Linux Installation HOWTO. Boot the Linux machine from SAR disk #1.
  340.   When prompted, insert disk #2.  Now, follow the directions in the file
  341.   /root/notes (this was /tape144/root/notes when it was mounted on your
  342.   Linux machine).  Once both machines have been booted up, run the
  343.   recovery routine you need.  If you are running the backup scripts you
  344.   can do it as follows:
  345.  
  346.   1. change directory to the mount point of the hard disk partition
  347.      which you will be recovering.
  348.  
  349.   2. if any mounted volumes are on the backup, and you want to recover
  350.      them, create the mount points within the hard disk partition and
  351.      mount the volumes.
  352.  
  353.   3. Enter the command:
  354.  
  355.        rsh -n msdos dd if=/dev/ftape | afio -i -v -Z -c 1024 -
  356.  
  357.   or
  358.  
  359.        rsh -n -l tapeuser msdos dd if=/dev/ftape | afio -i -v -Z -c 1024 -
  360.  
  361.   or
  362.  
  363.        mknod /tmp/backpipe p
  364.        rsh -n msdos dd if=/dev/ftape >> /tmp/backpipe &
  365.        afio -i -v -Z -c 1024 /tmp/backpipe
  366.  
  367.   This reads the tape on the remote machine, writing the result to std¡
  368.   out, where afio picks it up.  The '-i' switch tells it to recover the
  369.   files relative to the current working directory (which is the root of
  370.   the hard disk partition).  '-v' is verbose, listing the files as they
  371.   are recovered.  '-Z' tells afio that this is an archive of individu¡
  372.   ally compressed files.  '-c 1024' tells it to use a 5 MB streaming
  373.   buffer to avoid a lot of tape rewinding.
  374.  
  375.   3.  Notes
  376.  
  377.   The commands listed in the /tape144/root/notes file could be run from
  378.   a script.  When I tried, I got rpc setup errors.  I suspect it was
  379.   just that the commands were run too quickly, and the portmapper hadn't
  380.   properly installed itself.  I found that typing the sequence in
  381.   manually worked fine, so I've recommended that.
  382.  
  383.   I think this setup is secure.  Note that somebody can still get access
  384.   to all your files if they go to the tape drive and pull the tape out
  385.   before you get there, then then read the tape themselves.  People with
  386.   very sensitive data might consider encrypting the stream from the
  387.   archiver.  Archive to standard output and pipe the output to the
  388.   encrypter, and redirect the output of the encrypter to append to the
  389.   named pipe /tmp/tapepipe as described above. Note that errors in the
  390.   recovery process will result in all files after that point being
  391.   unrecoverable, as the entire archive is now a single DES-encrypted
  392.   stream.  It is possible to use options on afio to send each file in
  393.   the archive first through gzip, then into an encryption program like
  394.   des, but note that this compressing first does provide a fair amount
  395.   of known plaintext for determined code breakers to work with, so a
  396.   better approach might be to skip the gzip step and simply encrypt it
  397.   with des, at the expense of significantly more tape area. Needless to
  398.   say, DES encrypted files don't compress.
  399.  
  400.   The rc.inet1 directions I've included will allow only communication
  401.   with the local network, not the rest of the world through a gateway.
  402.  
  403.   During a full recovery to a blank hard disk the SAR disk #3 provides
  404.   ftape.o to the MS-DOS machine through NFS.  This is because some old
  405.   versions of the ftape module can't control some tape drives when there
  406.   is a disk mounted in the floppy drive. With newer kernels, the entire
  407.   NFS stuff can be omitted.
  408.  
  409.   This is very important.  ***TEST*** the SAR recovery procedure.  I
  410.   did, but don't leave anything to chance.  Make sure that you can
  411.   recover at least one file from your tape to the Linux machine using
  412.   only the SAR disks (i.e. without mounting the hard disk).  If you
  413.   can't reboot the Linux machine without inconveniencing a lot of users,
  414.   change the setup information on the SAR disks to assign the ``linux''
  415.   identity to another MS-DOS machine and then boot the two MS-DOS
  416.   machines into Linux to make sure everything works.  Then, change the
  417.   ``linux'' identity back again so that you have usable SAR disks.
  418.  
  419.   4.  Copyright
  420.  
  421.   Copyright Jan 10, 1995 by Christopher Neufeld
  422.   (neufeld@physics.utoronto.ca)
  423.  
  424.   Modified Feb 6, 1996.
  425.  
  426.   Modified Aug 5, 1997.
  427.  
  428.